And use it in the color widgets.
#include "gtkbutton.h"
#include "gtkmain.h"
#include "gtkcolorchooser.h"
+#include "gtkcolorchooserprivate.h"
#include "gtkcolorchooserdialog.h"
#include "gtkdnd.h"
#include "gtkdrawingarea.h"
return button->priv->use_alpha && button->priv->rgba.alpha < 1;
}
-static cairo_pattern_t *
-gtk_color_button_get_checkered (void)
-{
- /* need to respect pixman's stride being a multiple of 4 */
- static unsigned char data[8] = { 0xFF, 0x00, 0x00, 0x00,
- 0x00, 0xFF, 0x00, 0x00 };
- static cairo_surface_t *checkered = NULL;
- cairo_pattern_t *pattern;
-
- if (checkered == NULL)
- {
- checkered = cairo_image_surface_create_for_data (data,
- CAIRO_FORMAT_A8,
- 2, 2, 4);
- }
-
- pattern = cairo_pattern_create_for_surface (checkered);
- cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
- cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);
-
- return pattern;
-}
-
/* Handle exposure events for the color picker's drawing area */
static gint
gtk_color_button_draw_cb (GtkWidget *widget,
cairo_set_source_rgb (cr, CHECK_LIGHT, CHECK_LIGHT, CHECK_LIGHT);
cairo_scale (cr, CHECK_SIZE, CHECK_SIZE);
- checkered = gtk_color_button_get_checkered ();
+ checkered = _gtk_color_chooser_get_checkered_pattern ();
cairo_mask (cr, checkered);
cairo_pattern_destroy (checkered);
gtk_style_context_get_background_color (context, GTK_STATE_FLAG_INSENSITIVE, &color);
gdk_cairo_set_source_rgba (cr, &color);
- checkered = gtk_color_button_get_checkered ();
+ checkered = _gtk_color_chooser_get_checkered_pattern ();
cairo_mask (cr, checkered);
cairo_pattern_destroy (checkered);
}
if (GTK_COLOR_CHOOSER_GET_IFACE (chooser)->add_palette)
GTK_COLOR_CHOOSER_GET_IFACE (chooser)->add_palette (chooser, horizontal, colors_per_line, n_colors, colors);
}
+
+cairo_pattern_t *
+_gtk_color_chooser_get_checkered_pattern (void)
+{
+ /* need to respect pixman's stride being a multiple of 4 */
+ static unsigned char data[8] = { 0xFF, 0x00, 0x00, 0x00,
+ 0x00, 0xFF, 0x00, 0x00 };
+ static cairo_surface_t *checkered = NULL;
+ cairo_pattern_t *pattern;
+
+ if (checkered == NULL)
+ checkered = cairo_image_surface_create_for_data (data,
+ CAIRO_FORMAT_A8,
+ 2, 2, 4);
+
+ pattern = cairo_pattern_create_for_surface (checkered);
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+ cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);
+
+ return pattern;
+}
void _gtk_color_chooser_color_activated (GtkColorChooser *chooser,
const GdkRGBA *color);
+cairo_pattern_t * _gtk_color_chooser_get_checkered_pattern (void);
+
G_END_DECLS
#endif /* ! __GTK_COLOR_CHOOSER_PRIVATE_H__ */
#include "gtkcolorscaleprivate.h"
+#include "gtkcolorchooserprivate.h"
#include "gtkcolorutils.h"
#include "gtkorientable.h"
#include "gtkstylecontext.h"
G_DEFINE_TYPE (GtkColorScale, gtk_color_scale, GTK_TYPE_SCALE)
-static cairo_pattern_t *
-get_checkered_pattern (void)
-{
- /* need to respect pixman's stride being a multiple of 4 */
- static unsigned char data[8] = { 0xFF, 0x00, 0x00, 0x00,
- 0x00, 0xFF, 0x00, 0x00 };
- static cairo_surface_t *checkered = NULL;
- cairo_pattern_t *pattern;
-
- if (checkered == NULL)
- checkered = cairo_image_surface_create_for_data (data,
- CAIRO_FORMAT_A8,
- 2, 2, 4);
-
- pattern = cairo_pattern_create_for_surface (checkered);
- cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
- cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);
-
- return pattern;
-}
-
static void
create_surface (GtkColorScale *scale)
{
cairo_paint (cr);
cairo_set_source_rgb (cr, 0.66, 0.66, 0.66);
- pattern = get_checkered_pattern ();
+ pattern = _gtk_color_chooser_get_checkered_pattern ();
cairo_matrix_init_scale (&matrix, 0.125, 0.125);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_mask (cr, pattern);
#include "gtkcolorswatchprivate.h"
+#include "gtkcolorchooserprivate.h"
#include "gtkroundedboxprivate.h"
#include "gtkthemingbackgroundprivate.h"
#include "gtkdnd.h"
#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
-static cairo_pattern_t *
-get_checkered_pattern (void)
-{
- /* need to respect pixman's stride being a multiple of 4 */
- static unsigned char data[8] = { 0xFF, 0x00, 0x00, 0x00,
- 0x00, 0xFF, 0x00, 0x00 };
- static cairo_surface_t *checkered = NULL;
- cairo_pattern_t *pattern;
-
- if (checkered == NULL)
- checkered = cairo_image_surface_create_for_data (data,
- CAIRO_FORMAT_A8,
- 2, 2, 4);
-
- pattern = cairo_pattern_create_for_surface (checkered);
- cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
- cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);
-
- return pattern;
-}
-
static gboolean
swatch_draw (GtkWidget *widget,
cairo_t *cr)
cairo_set_source_rgb (cr, 0.33, 0.33, 0.33);
cairo_fill_preserve (cr);
- pattern = get_checkered_pattern ();
+ pattern = _gtk_color_chooser_get_checkered_pattern ();
cairo_matrix_init_scale (&matrix, 0.125, 0.125);
cairo_pattern_set_matrix (pattern, &matrix);